<template>
  <el-container class="home-container">
    <!-- 页面主体区 -->
    <el-container>
      <!-- 侧边栏 -->
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <!-- 侧边栏菜单区 -->
        <div class="toggle-button" @click="toggleCollaspe">|||</div>
        <el-menu
          :router="true"
          :collapse-transition="false"
          :collapse="isCollapse"
          unique-opened
          background-color="#666"
          text-color="#EAEDF1"
          active-text-color="#FC5531"
          :default-active="$route.path"
        >
          <el-menu-item index="/admin">
            <i class="el-icon-s-home"></i>
            <span slot="title">首页</span>
          </el-menu-item>
          <el-menu-item index="/admin/topic">
            <i class="el-icon-tickets"></i>
            <span slot="title">留言管理</span>
          </el-menu-item>
          <el-menu-item index="/admin/user">
            <i class="el-icon-s-custom"></i>
            <span slot="title">用户管理</span>
          </el-menu-item>
          <el-menu-item index="/admin/type">
            <i class="el-icon-menu"></i>
            <span slot="title">分类管理</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <!-- 右侧主题 -->
      <el-main>
        <!-- 路由占位符 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      // 左侧菜单数据
      isCollapse: false,
      // 被激活的链接地址
      activePath: '',
    };
  },
  methods: {
    // 点击按钮切换菜单折叠与展开
    toggleCollaspe() {
      this.isCollapse = !this.isCollapse;
    },
  },
};
</script>

<style lang="less" scoped>
.home-container {
  width: 100%;
  height: calc(100% - 50px);
}
.el-aside {
  background-color: #444;
  .el-menu {
    border-right: none;
  }
}
.el-main {
  background-color: #eaedf1;
}

.iconfont {
  margin-right: 10px;
}
.toggle-button {
  background-color: #555;
  text-align: center;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>
